<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of kmeans2</title>
  <meta name="keywords" content="kmeans2">
  <meta name="description" content="Fast version of kmeans clustering.">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../m2html.css">
</head>
<body>
<a name="_top"></a>
<!-- menu.html classify -->
<h1>kmeans2
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>Fast version of kmeans clustering.</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>function [ IDX, C, d ] = kmeans2( X, k, varargin ) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre class="comment"> Fast version of kmeans clustering.

 Cluster the N x p matrix X into k clusters using the kmeans algorithm. It
 returns the cluster memberships for each data point in the N x 1 vector
 IDX and the K x p matrix of cluster means in C.

 This function is in some ways less general than Matlab's kmeans.m (for
 example it only uses euclidian distance), but it has some options that
 the Matlab version does not (for example, it has a notion of outliers and
 min-cluster size).  It is also many times faster than matlab's kmeans.
 General kmeans help can be found in help for the matlab implementation of
 kmeans. Note that the although the names and conventions for this
 algorithm are taken from Matlab's implementation, there are slight
 alterations (for example, IDX==-1 is used to indicate outliers).

 IDX is a n-by-1 vector used to indicated cluster membership.  Let X be a
 set of n points.  Then the ID of X - or IDX is a column vector of length
 n, where each element is an integer indicating the cluster membership of
 the corresponding element in X.  IDX(i)=c indicates that the ith point in
 X belongs to cluster c. Cluster labels range from 1 to k, and thus
 k=max(IDX) is typically the number of clusters IDX divides X into. The
 cluster label &quot;-1&quot; is reserved for outliers. IDX(i)==-1 indicates that
 the given point does not belong to any of the discovered clusters. Note
 that matlab's version of kmeans does not have outliers.

 USAGE
  [ IDX, C, d ] = kmeans2( X, k, [varargin] )

 INPUTS
  X       - [n x p] matrix of n p-dim vectors.
  k       - maximum nuber of clusters (actual number may be smaller)
  prm     - additional params (struct or name/value pairs)
   .k         - [] alternate way of specifying k (if not given above)
   .nTrial    - [1] number random restarts
   .maxIter   - [100] max number of iterations
   .display   - [0] Whether or not to display algorithm status
   .rndSeed   - [] random seed for kmeans; useful for replicability
   .outFrac   - [0] max frac points that can be treated as outliers
   .minCl     - [1] min cluster size (smaller clusters get eliminated)
   .metric    - [] metric for pdist2
   .C0        - [] initial cluster centers for first trial

 OUTPUTS
  IDX    - [n x 1] cluster membership (see above)
  C      - [k x p] matrix of centroid locations C(j,:) = mean(X(IDX==j,:))
  d      - [1 x k] d(j) is sum of distances from X(IDX==j,:) to C(j,:)
           sum(d) is a typical measure of the quality of a clustering

 EXAMPLE

 See also <a href="demoCluster.html" class="code" title="">DEMOCLUSTER</a>

 Piotr's Computer Vision Matlab Toolbox      Version 3.24
 Copyright 2014 Piotr Dollar.  [pdollar-at-gmail.com]
 Licensed under the Simplified BSD License [see external/bsd.txt]</pre></div>





<!-- Start of Google Analytics Code -->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-4884268-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>
<!-- end of Google Analytics Code -->

<hr><address>Generated by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" target="_parent">m2html</a></strong> &copy; 2003</address>
</body>
</html>
